Imports System.Windows.Forms

Public Class ExclList

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        If Me.lsItems.Items.Count = 0 Then
            ReDim MainDlg.sExclLst(-1)
        Else
            ReDim MainDlg.sExclLst(0 To Me.lsItems.Items.Count - 1)
            Dim i As Integer
            For i = 0 To Me.lsItems.Items.Count - 1
                MainDlg.sExclLst(i) = Me.lsItems.Items(i)
            Next
        End If
        Me.Close()
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Private Sub ExclList_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        UTIL.SaveStg("EXLDLG", "Win_l", Me.Left)
        UTIL.SaveStg("EXLDLG", "Win_t", Me.Top)
        UTIL.SaveStg("EXLDLG", "Win_w", Me.Width)
        UTIL.SaveStg("EXLDLG", "Win_h", Me.Height)
    End Sub

    Private Sub ExclList_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Left = UTIL.GetLongStg("EXLDLG", "Win_l", 200)
        Me.Top = UTIL.GetLongStg("EXLDLG", "Win_t", 100)
        Me.Width = UTIL.GetLongStg("EXLDLG", "Win_w", 338)
        Me.Height = UTIL.GetLongStg("EXLDLG", "Win_h", 230)
        If UBound(MainDlg.sExclLst) <> -1 Then
            Dim i As Integer
            For i = 0 To UBound(MainDlg.sExclLst)
                Me.lsItems.Items.Add(MainDlg.sExclLst(i))
            Next
        End If
    End Sub

    Private Sub bAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bAdd.Click
        Dim sTmpT As String = Me.txAdd.Text.Trim.ToUpper
        If sTmpT.Length = 0 Then
            MsgBox("Invalid string")
            Return
        Else
            For i As Integer = 0 To Me.lsItems.Items.Count - 1
                If Me.lsItems.Items(i) = sTmpT Then
                    MsgBox("Already in list")
                    Return
                End If
            Next
        End If
        Me.lsItems.Items.Add(sTmpT)
        Me.txAdd.Text = ""
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If Me.lsItems.SelectedItems.Count = 0 Then
            MsgBox("Nothing is selected")
            Return
        End If
        While (Me.lsItems.SelectedItems.Count > 0)
             Me.lsItems.Items.Remove(Me.lsItems.SelectedItems(0))
        End While
    End Sub

    Private Sub bDef_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bDef.Click
        Me.lsItems.Items.Clear()
        Me.lsItems.Items.Add("TEMP")
        Me.lsItems.Items.Add("RECYCLER")
        Me.lsItems.Items.Add("SYSTEM VOLUME INFORMATION")
        Me.lsItems.Items.Add("$AVG")
        Me.lsItems.Items.Add("TRAPEZ")
        Me.lsItems.Items.Add("POZE")
    End Sub

    Private Sub bClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bClear.Click
        Me.lsItems.Items.Clear()
    End Sub


    Private Sub bSelAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bSelAll.Click
        Dim i As Integer = Me.lsItems.Items.Count
        If i = 0 Then
            MsgBox("Nothing to select")
        End If
        For j As Integer = 0 To i - 1
            Me.lsItems.SetSelected(j, True)
        Next
    End Sub


    Private Sub bInvSel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bInvSel.Click
        Dim i As Integer = Me.lsItems.Items.Count
        If i = 0 Then
            MsgBox("Nothing to select")
        End If
        For j As Integer = 0 To i - 1
            Me.lsItems.SetSelected(j, Not Me.lsItems.GetSelected(j))
        Next

    End Sub
End Class

